﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace elctronixMVC.Models
{
    public class Menu
    {

        public int menuID;
        public string menucontent;
        public string menulink;
        public string imgpath;





        public static List<Menu> menulergetir()
        {
            List<Menu> menu = new List<Menu>();
            SqlConnection sqlcon = connection.baglanti;
            SqlCommand sqlcmd = new SqlCommand("select * from menubar", sqlcon);
            sqlcon.Open();
            SqlDataReader sdr = sqlcmd.ExecuteReader();
            while (sdr.Read())
            {
                Menu m = new Menu();
                m.menuID = Convert.ToInt32(sdr["ID"]);
                m.menucontent = sdr["menucontent"].ToString();
                m.menulink = sdr["controller"].ToString();  //webformda burasi , menulink ti...MVC de controller a cevirdim.degisken ismi aynı kaldı.okudugu kolon ismini degistirdim,controller yaptım
                m.imgpath = sdr["menuimg"].ToString();
                menu.Add(m);
            }
            sqlcon.Close();
            return menu;
        }









    }
}